
import request from '@/utils/request'


export default {
  namespaced: true,
  state: {
    info:{},
    shopName:'',
    shopList:[],
    createBy:'',
  },
  mutations: {
      SET_SHOPINFO(state,shopInfo){
        state.info = shopInfo  
      },

      SET_SHOPLIST(state,shopList){
        state.shopList = shopList
      }
  },
  actions: {
        async getShopInfo({commit,state}){
          await request.get('/schoolOrder/app/shop/findShopInfoByCreateBy',{
            params:{
                createBy: sessionStorage.getItem('createBy') ? sessionStorage.getItem('createBy')  : state.createBy
              }
          }).then(
            res => {
              commit('SET_SHOPINFO',res.data.data)
            }
          )
        },
        
        async getShopByPage({commit},params){
            await request.get('/schoolOrder/app/shop/findShopByPage',{
              params:{
                pageNum:params.pageNum,
                pageSize:params.pageSize
              }
            }).then(
              res => {
                commit("SET_SHOPLIST",res.data.data.records)
              }
            )
        }
  },

}
